/**
 * Created by xjweng on 2017/1/5.
 */
var phoneList = angular.module('phoneList',['core.phone']);
phoneList.directive("phoneList",function () {
    return {
        restrict: 'E',
        //scope属性的值为false，true，{ } 分别对应着上面的所在作用域，子作用域，隔离作用域
        scope:true,
        templateUrl: 'phone-list/phone-list.template.html',
        /*template: ['<ul>',
            '<li ng-repeat="phone in phones2 | filter:query | orderBy:orderProp">',
            '<span>{{phone.name}}</span>',
            '<p>{{phone.snippet}}</p>',
            '</li>',
            '</ul>'].join("\n"),*/
        controller: 'PhoneListController',
        link:function (scope) {
/*            scope.phones2 = [
                {
                    name: 'Nexus S',
                    snippet: 'Fast just got faster with Nexus S.',
                    age: 1
                }, {
                    name: 'Motorola XOOM™ with Wi-Fi',
                    snippet: 'The Next, Next Generation tablet.',
                    age: 3
                }, {
                    name: 'MOTOROLA XOOM™',
                    snippet: 'The Next, Next Generation tablet.',
                    age: 2
                }
            ];*/
            //只是隔离scope能用
            //scope.orderProp = 'age';
        }
    }
})
    .controller('PhoneListController',["$scope","$location","$http","Phone",
        function ($scope,$location,$http,Phone) {
        /*    $scope.phones = [
         {
         name: 'Nexus S',
         snippet: 'Fast just got faster with Nexus S.'
         },{
         name: 'Motorola XOOM™ with Wi-Fi',
         snippet: 'The Next, Next Generation tablet.'
         },{
         name: 'MOTOROLA XOOM™',
         snippet: 'The Next, Next Generation tablet.'
         }
         ];*/
        $scope.name = "hello world";
        $scope.myUrl = $location.absUrl();
        $scope.orderProp = 'age';
        /*  $http方法*/
        /*$http.get('phones/phones.json').then(function (response) {
            $scope.phones = response.data;
            console.log(response);
        });*/
        $scope.phones = Phone.query();
        console.log(Phone.query());
    }])